package com.crocodileQ.controller;

import com.crocodileQ.common.R;
import com.crocodileQ.domain.entity.User;
import com.crocodileQ.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

@RestController
@RequestMapping("/admin")
public class LoginController {

    @Autowired
    private LoginService loginService;

    /**
     * 用户登录
     * @param user
     * @return
     */
    @PostMapping("/login")
    public R<HashMap> login(@RequestBody User user){


        return loginService.login(user);
    }

    /**
     * 用户退出登录
     * @return
     */
    @PostMapping("/logout")
    public R logout(){

        return loginService.logout();
    }
}
